<?php


use Swoole\WebSocket\Server;

class Swoole
{


    function __construct()
    {

        $config=[
            'worker_num'=>3,
            'daemonize '=>0
        ];

        $server=new Server('0.0.0.0',9500);


        $server->set($config);

        $server->on('start',[$this,'start']);

        $server->on('open',[$this,'open']);

        $server->on('message',[$this,'message']);

        $server->on('close',[$this,'close']);

        $server->start();
    }

    function start(Server $server){

        echo 'server is starting'.PHP_EOL;
    }

    function open(Server $server,swoole_http_request $request){



    }

    function message(swoole_websocket_server $server,swoole_websocket_frame $frame){



        $server->push($frame->fd,$frame->data);

        echo $frame->data.PHP_EOL;

    }

    function close(swoole_websocket_server $server,int $fd,int $reactorId){


    }
}


new Swoole();
